<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            新闻标题：<input type="text" name="newsTitle"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:news:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:news:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<script src="${ctx}/static/js/wangEditor.min.js"></script>
<script>
    var prefix = "${ctx}/system/news";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "新闻",
            search: false,
            showExport: false,
            showColumns: false,
            showToggle: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'newsId',
                    title: '新闻编码',
                    visible: false
                },
                {
                    field: 'newsTitle',
                    title: '新闻标题',
                    formatter: function (value, row, index) {
                        return row.newsTitle.length > 20 ? row.newsTitle.substr(0, 17) + "..." : row.newsTitle;
                    }
                },
                {
                    field: 'newsTop',
                    title: '是否置顶',
                    formatter: function (value, row, index) {
                        return row.newsTop == '0' ? '置顶' : '';
                    }
                },
                {
                    field: 'newsType',
                    title: '类型',
                    formatter: function (value, row, index) {
                        return value == 0 ? '新闻发布' : '税务政策';
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                },
                {
                    field: 'createBy',
                    title: '创建人',
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="#" onclick="$.operate.edit(\'' + row.newsId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="$.operate.remove(\'' + row.newsId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>